<script type="text/javascript" src="<?=base_url()?>js/jquery.jqprint.0.3.js"></script>
<script type="text/javascript">
 function printdiv()
 {
   $j('#print_logo').show();
   $j('#printable').jqprint();
   $j('#print_logo').hide();
 }
</script>
<div id="store">
  <div class="page-content">
     <?php if($result == "success") 
	  { 
	  ?>
       <div id="printable">
             <div id="print_logo" style="display:none"><img src="<?=base_url()?>img/header-logo.jpg" alt="7 Eleven" /><br/></div>
             <h2>Order Status</h2>
                <div class="msg"><h4 class="success">Success</h4>
                    <p>Congratulations <b><?php 
					$user = $this->session->userdata('7elevencloggedin'); 
					$customer = $this->Customer_model->identify($user['customer_id']); print 'store #'.$customer['storeno']; ?></b> your order has gone through sucsessfully and your products are in the process of being delivered. Please record your order details below as order receipt.</p><br/>
                    <?php $order = $this->Order_model->identify($this->session->userdata('order_id'));
					$cart  = $this->Cart_model->all($order['session_id']);
					if($order != NULL)
					{
						?>
                    <h3>Order Details</h3>
				     <table cellpadding=0 cellspacing="0" border="0">
                       <tr height="38"><td width="110">Order Number</td>
                           <td><?php printf('%04d',$order['id']);?></td>
                       </tr>
                       <tr height="38"><td width="110" valign="top">Purchased Items</td>
                           <td >
                              <table border="0">
						   <?php foreach($cart as $item) 
					       { 
					         $product = $this->Product_model->identify($item['product_id']);
					       ?>
                              <tr><td>$<?=$item['price']?></td><td width="10">&nbsp;</td><td><?=$item['quantity']?> x <?php if(!empty($product['title'])) echo $product['title'];?></td>
                                  <td width="10">&nbsp;</td><td><?php echo $item['attributes'];?></td>
                              </tr>
						  <?
					       }
				           ?>
                             </table>
					       </td>
                       </tr>
                       <tr height="38"><td width="110">Sub total</td>
                           <td>$<?=$order['subtotal']?></td>
                       </tr>
                       <tr height="38"><td width="110">Tax</td>
                           <td>$<?=$order['tax']?></td>
                       </tr>
                       <?php if($order['discount'] > 0) 
					   { 
					    $coupon = $this->System_model->check_coupon_code($order['coupon_code']);
				    	$value = $coupon['value'];
					    if ($coupon['type'] == 1) 
						{ 
						$amount = money_format('%i',floatval($value) * floatval($order['subtotal'] + $order['tax'])/100);
						$value = $value.'% (-$'.$amount.')'; 
					    } 
						else 
						{ 
						$value = '$'.$value; 
						}
				        ?>
                        <tr height="38"><td>Discount</td><td>-<?=$value?></td></tr>
                        <?php 
				        } 
                       ?>
                       <tr height="38"><td width="110">Total</td>
                           <td>$<?=$order['total']?></td>
                       </tr>
                      
                       <tr height="38"><td width="110">Address</td><td><?=$order['address']?></td></tr>
                       <tr height="38"><td width="110">Suburb</td><td><?=$order['suburb']?></td></tr>
                       <tr height="38"><td width="110">Postcode</td><td><?=$order['postcode']?></td></tr>
                       <tr height="38"><td width="110">State</td><td><?=$order['state']?></td></tr>   
                    </table>
                    <?php
					}
					?>
                 </div>
                    
                </div>
               <br/><form>
<input type="button" value="Print this order" onclick="printdiv()">
</form>
            </div>
            <?php 
			} 
			 ?>                
        </div>